<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理界面</title>
</head>
<body>
{{ today }} 打印订单

<br>
当前登录用户：{{ current_user.Tel_Number }}
<br>

<a href="http://127.0.0.1:5000/admin/new_index">主页</a><br>


{{ query_form.hidden_tag() }}
{% if current_user.Role == 'admin' %}
{{ query_form.tel_number.label }}
{{ query_form.tel_number }}
<br>
订单{{ query_form.date_time.label }}
{{ query_form.date_time(type="date") }}
<br>
{{ query_form.submit(id="to_json") }}
{% endif %}

{% if current_user.Role == 'guest' %}
订单{{ query_form.date_time.label }}
{{ query_form.date_time(type="date") }}
<br>
{{ query_form.submit(id="to_guest") }}
{% endif %}

<table>

    <thead>

    <tr>
        <th>文件名</th>
        <th>份数</th>
        <th>方向</th>
        <th>单彩</th>
        <th>方式</th>
        <th>状态</th>
        <th>订单号</th>
        {#        <th>预览</th>#}
    </tr>

    </thead>
    <tbody id="append_json">
    {% for info in infos %}
        {% if info.Born_Date_Day == today %}
            <tr>
                <td style="text-align: center">
                    {% if info.File_Dir[-3:] == "pdf" %}
                        <a href='#' onclick="window.open('look/viewer.html?file=../../static/Upload_Files/{{ info.File_Dir }}','PDF','width:50%;height:50%;top:100;left:100;');">
                            {{ info.File_Name[:-4] }}{{ info.File_Dir[-4:] }}
                        </a>
                    {% endif %}
                    {% if info.File_Dir[-3:] != "pdf" %}
                        <a href="look_picture/{{ info.File_Dir }}">
                            {{ info.File_Name[:-4] }}{{ info.File_Dir[-4:] }}
                        </a>
                    {% endif %}
                </td>
                <td style="text-align: center">{{ info.Print_Copies }}</td>
                <td style="text-align: center">
                    {% if info.Print_Direction == 3 %}
                        <p>纵向</p>
                    {% endif %}
                    {% if info.Print_Direction == 4 %}
                        <p>横向</p>
                    {% endif %}
                </td>
                <td style="text-align: center">
                    {% if info.Print_Colour == 'mono' %}
                        <p>黑白</p>
                    {% endif %}
                    {% if info.Print_Colour == 'color' %}
                        <p>彩色</p>
                    {% endif %}
                </td>
                <td style="text-align: center">
                    {% if info.Print_way == 'one-sided' %}
                        <p>单面</p>
                    {% endif %}
                    {% if info.Print_way == 'two-sided-long-edge' %}
                        <p>双面长边</p>
                    {% endif %}
                    {% if info.Print_way == 'two-sided-short-edge' %}
                        <p>双面短边</p>
                    {% endif %}
                </td>

                <td style="text-align: center">
                    {% if info.Print_Status == 0 %}
                        <p>未支付</p>
                    {% endif %}
                    {% if info.Print_Status == 1 %}
                        <p>已支付</p>
                    {% endif %}
                    {% if info.Print_Status == 2 %}
                        <p>正在打印</p>
                    {% endif %}
                    {% if info.Print_Status == 3 %}
                        <p>打印结束</p>
                    {% endif %}
                </td>
                <td style="text-align: center">{{ info.Trade_Number }}</td>
            </tr>
        {% endif %}
    {% endfor %}
    </tbody>
</table>

{% from "bootstrap/pagination.html" import render_pagination %}
{% if pagination %}
<div id="pagination" class="page-footer">{{ render_pagination(pagination) }}</div>
{% endif %}


<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

{% if current_user.Role == 'admin' %}
<script type="text/javascript">
    $(function () {
        $('#to_json').click(function () {
            $('div#pagination').empty();
            $('tbody#append_json').empty();
            $.ajax({
                url: '/jsons/date_time',
                dataType: 'json',
                type: 'get',
                data: {
                    'csrf_token': $('input#csrf_token').val(),
                    'tel_number': $('input#tel_number').val(),
                    'date_time': $('input#date_time').val()
                },
                success: function (data) {
                    for (var i = 0; i < data.length; ++i) {
                        var str = "<tr>";
                        var lb = data[i].File_Dir.substr(-3, 3);
                        console.log(lb);
                        if (lb == 'pdf') {
                            str += "<th id=\"file_name\" style=\"width: 20%\"><a href='#' onclick=\"window.open('look_pdf/viewer.html?file=../../static/Upload_Files/" + data[i].File_Dir + "','PDF','width:50%;height:50%;top:100;left:100;');\">" + data[i].File_Name + "</th>";
                        } else {
                            str += "<th id=\"file_name\" style=\"width: 20%\"><a href='look_picture/" + data[i].File_Dir + "'>" + data[i].File_Name + "</th>";
                        }
                        str += "<th id=\"copes\">" + data[i].Print_Copies + "</th>"
                        if (data[i].Print_Direction == 3) {
                            str += "<th id=\"Direction\">纵向</th>"
                        } else {
                            str += "<th id=\"Direction\">横向</th>"
                        }
                        if (data[i].Print_Colour == 'mono') {
                            str += "<th id=\"color\">灰度</th>"
                        } else {
                            str += "<th id=\"color\">彩色</th>"
                        }
                        if (data[i].Print_way == 'one-sided') {
                            str += "<th id=\"way\">单面</th>"
                        }
                        if (data[i].Print_way == 'two-sided-long-edge') {
                            str += "<th id=\"way\">双面长边</th>"
                        }
                        if (data[i].Print_way == 'two-sided-short-edge') {
                            str += "<th id=\"way\">双面短边</th>"
                        }
                        if (data[i].Print_Status == 0) {
                            str += "<th id=\"status\">未支付</th>"
                        }
                        if (data[i].Print_Status == 1) {
                            str += "<th id=\"status\">已支付</th>"
                        }
                        if (data[i].Print_Status == 2) {
                            str += "<th id=\"status\">准备打印</th>"
                        }
                        if (data[i].Print_Status == 3) {
                            str += "<th id=\"status\">打印完成</th>"
                        }
                        str += "<th id=\"trade_number\">" + data[i].Trade_Number + "</th>"
                        str += "</tr>"
                        $('tbody#append_json').append(str)
                    }
                }
            })

        })
    })
</script>
{% endif %}

{% if current_user.Role == 'guest' %}
<script type="text/javascript">
    $(function () {
        $('#to_guest').click(function () {
            $('div#pagination').empty();
            $('tbody#append_json').empty();
            $.ajax({
                url: '/jsons/date_time',
                dataType: 'json',
                type: 'get',
                data: {
                    'csrf_token': $('input#csrf_token').val(),
                    'date_time': $('input#date_time').val()
                },
                success: function (data) {
                    for (var i = 0; i < data.length; ++i) {
                        var str = "<tr>";
                        var lb = data[i].File_Dir.substr(-3, 3);
                        console.log(lb);
                        if (lb == 'pdf') {
                            str += "<th id=\"file_name\" style=\"width: 20%\"><a href='#' onclick=\"window.open('look_pdf/viewer.html?file=../../static/Upload_Files/" + data[i].File_Dir + "','PDF','width:50%;height:50%;top:100;left:100;');\">" + data[i].File_Name + "</th>";
                        } else {
                            str += "<th id=\"file_name\" style=\"width: 20%\"><a href='look_picture/" + data[i].File_Dir + "'>" + data[i].File_Name + "</th>";
                        }
                        str += "<th id=\"copes\">" + data[i].Print_Copies + "</th>"
                        if (data[i].Print_Direction == 3) {
                            str += "<th id=\"Direction\">纵向</th>"
                        } else {
                            str += "<th id=\"Direction\">横向</th>"
                        }
                        if (data[i].Print_Colour == 'mono') {
                            str += "<th id=\"color\">灰度</th>"
                        } else {
                            str += "<th id=\"color\">彩色</th>"
                        }
                        if (data[i].Print_way == 'one-sided') {
                            str += "<th id=\"way\">单面</th>"
                        }
                        if (data[i].Print_way == 'two-sided-long-edge') {
                            str += "<th id=\"way\">双面长边</th>"
                        }
                        if (data[i].Print_way == 'two-sided-short-edge') {
                            str += "<th id=\"way\">双面短边</th>"
                        }
                        if (data[i].Print_Status == 0) {
                            str += "<th id=\"status\">未支付</th>"
                        }
                        if (data[i].Print_Status == 1) {
                            str += "<th id=\"status\">已支付</th>"
                        }
                        if (data[i].Print_Status == 2) {
                            str += "<th id=\"status\">准备打印</th>"
                        }
                        if (data[i].Print_Status == 3) {
                            str += "<th id=\"status\">打印完成</th>"
                        }
                        str += "<th id=\"trade_number\">" + data[i].Trade_Number + "</th>"
                        str += "</tr>"
                        $('tbody#append_json').append(str)
                    }
                }
            })

        })
    })
</script>
{% endif %}

{#{% from "bootstrap/pagination.html" import render_pagination %}#}
{#{% if pagination %}#}
{#    <div>{{ render_pagination(pagination) }}</div>#}
{#{% endif %}#}

</body>
</html>